package kr.pfg.pfgTracer.model.vo
{
	import flash.events.EventDispatcher;
	import flash.net.LocalConnection;
	
	import kr.pfg.pfgTracer.model.event.ReceiveMessageEvent;
	import kr.pfg.pfgTracer.model.event.ReceiveSwfInfoEvent;
	
	public class EchoClient extends EventDispatcher
	{
		private var localConnect: LocalConnection; 
		
		public var key: String;
		public function EchoClient ( _key: String )
		{
			localConnect = new LocalConnection();
			localConnect.allowDomain("*");
			localConnect.client = this;
			localConnect.connect( _key );
			key = _key;
		}				
		
		/*
		//	name = 파일명;
		//	version = player 버전
		//	frame = 프레임수
		//	actionV = 액션스크립트 버전 			
		*/
		public var swfMember: Array;
		public function swfInformation( name: String = "" , version: String = "", frame: String = "", actionV: String = "" ): void
		{
			swfMember = new Array();
			swfMember.push ( name, version, frame, actionV );
			
			
			this.dispatchEvent( new ReceiveSwfInfoEvent ( ReceiveSwfInfoEvent.DATA_SWFINFORMATION, swfMember ) );
		}
		
		public function message ( value: String, type: String ) : void
		{
			var data: Object = new Object();
			data.msg = value;
			data.type = type;
			data.key = key;
			
			this.dispatchEvent( new ReceiveMessageEvent ( ReceiveMessageEvent.DATA_RECEIVED, data ) );
		}
		
		public function quit(): void
		{
			trace ( " [ EchoClient Quit ] " )
		}
	}
}